package model;

import java.io.IOException;

public class Timing {
	private Game game;
	
	public Timing(Game pgame){
		game=pgame;
	}
	//egy utem telik a jatekban
	//minden dinamikus objektum mozgatasa
	public void tick() throws IOException {
		//az idot leptetjuk
		game.currentMap.daytime++;
		game.isGameOver();
		//ha elerte a 180-at akkor besotetedik
		if (game.currentMap.daytime==3600){
			game.currentMap.setNight(true);
			HedgeHog h=(HedgeHog) game.gameObjects.get(0);
			h.setActive(false);
		}
		//ha elerte a 300-at akkor vilagosodik
		if (game.currentMap.daytime==6000){
			game.currentMap.daytime=0;
			game.currentMap.setNight(false);
			HedgeHog h=(HedgeHog) game.gameObjects.get(0);
			h.setActive(true);
			h.antsEaten=0;
			game.killodor.capacity=20;
			game.killspray.capacity=20;
		}
		
		Object[] gm=game.gameObjects.toArray();
		for (int i=0;i<gm.length;i++){
			//hangya es a sun mozog
			if (!((GameObject)gm[i]).getType().equals("AntOdor")){
				((GameObject)gm[i]).move();
				
			}
			//a hangya szag osszemegy
			else{
				AntOdor ao=(AntOdor)gm[i];
				ao.dissipate();
			}
		}
	}

}
